package cn.smbms.controller;

import cn.smbms.pojo.Role;
import cn.smbms.service.role.RoleService;
import com.alibaba.fastjson.JSONArray;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/role")
public class RoleController {
    private Logger logger = Logger.getLogger(LoginController.class);

    @Resource
    public RoleService roleService;

   /* @RequestMapping(value = "/list.html",method = RequestMethod.GET)
    public String getRoleList(Model model){
        List<Role> roleList = roleService.getRoleList();
        model.addAttribute("roleList",roleList);
        return "/role/rolelist";
    }*/

    @RequestMapping(value="/getRoleList",method=RequestMethod.GET,produces = "application/json; charset=utf-8")
    @ResponseBody
    public Object getRole() {
        List<Role> roleList = new ArrayList<Role>();
        roleList=roleService.getRoleList();
        return JSONArray.toJSONString(roleList);
    }
}
